package S07.first;
public class Student implements Comparable<Student>{
    // 成员变量
    private String studentId; // 学号
    private String name;      // 姓名
    private int age;          // 年龄
    private double height;    // 身高（单位：米）
    private double weight;    // 体重（单位：千克）

    // 构造方法
    public Student(String studentId, String name, int age, double height, double weight) {
        this.studentId = studentId;
        this.name = name;
        this.age = age;
        this.height = height;
        this.weight = weight;
    }

    // Getter 和 Setter 方法
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    // 重写 toString 方法
    @Override
    public String toString() {
        return "Student{" +
                "studentId='" + studentId + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                "m, weight=" + weight +
                "kg" +
                '}';
    }

    // 测试方法
    public static void main(String[] args) {
        Student student = new Student("20240101", "张三", 20, 1.75, 65.5);
        System.out.println(student);
    }

	@Override
	public int compareTo(Student obj) {
//		return age-obj.age; //按年龄排序
//		return Double.compare(this.height, obj.height); //按身高来比较
		return studentId.compareTo(obj.studentId);//按学号比较大小
	}
}















